package com.yf.tz.entity;


import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单明细实体
 * 表名 mall_item
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Jul 21 11:03:42 CST 2020
 */
@Setter
@Getter
public class MallItemEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    //ID
    private Long id;
    //订单ID
    private Long orderId;
    //产品名
    private String name;
    //规格名
    private String skuName;
    //数量
    private Integer quantity;
    //规格ID
    private Long skuId;
    //产品ID
    private Long goodsId;
    //价格
    private BigDecimal price;
    //原价
    private BigDecimal oldPrice;
    //图片
    private String img;
    //产品重量
    private BigDecimal weight;
    //积分
    private BigDecimal point;


    public MallItemEntity() {

    }

    public MallItemEntity(Long orderId, String name, String skuName, Integer quantity, Long skuId, Long goodsId, BigDecimal price, BigDecimal oldPrice, String img, BigDecimal weight, BigDecimal point) {
        this.orderId = orderId;
        this.name = name;
        this.skuName = skuName;
        this.quantity = quantity;
        this.skuId = skuId;
        this.goodsId = goodsId;
        this.price = price;
        this.oldPrice = oldPrice;
        this.img = img;
        this.weight = weight;
        this.point = point;
    }

   public BigDecimal getTotalPrice() {
        if(this.price!=null&&this.quantity!=null){
            return this.price.multiply(new BigDecimal(this.quantity)).setScale(2);
        }
        return BigDecimal.ZERO;
    }
}
